using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;

namespace TableViewTest.Pages;

public partial class TestViewModel : ObservableObject
{
    public ObservableCollection<UserViewModel> Data { get; } = [];
    public DataTable DataTable { get; } = new();
    public ObservableCollection<object> ExpandoObjectData { get; } = [];
    public TestViewModel()
    {
        DataTable.Columns.Add(nameof(UserViewModel.ID), typeof(Guid));
        DataTable.Columns.Add(nameof(UserViewModel.Name), typeof(string));
        DataTable.Columns.Add(nameof(UserViewModel.Age), typeof(int));
        for (int i = 0; i < 1000; i++)
        {
            UserViewModel user = new() { Name = $"Name{i}", Age = i + 18 };
            Data.Add(user);
            DataTable.Rows.Add(user.ID, user.Name, user.Age);
            ExpandoObjectData.Add(new { user.ID, user.Name, user.Age });
        }
    }
}
